/*DECLARAÇÃO DAS VARIAVEIS*/
DEFINE VARIABLE pret       AS INTEGER.
DEFINE VARIABLE pCNPJ      AS CHAR.
DEFINE VARIABLE pCodigo    AS CHAR.
DEFINE VARIABLE pDescricao AS CHAR.
DEFINE VARIABLE paliq      AS CHAR.
DEFINE VARIABLE pTip_Qtd   AS CHAR.
DEFINE VARIABLE pQtd       AS CHAR.
DEFINE VARIABLE pCas_dec   AS INTEGER.
DEFINE VARIABLE pPrc_Uni   AS CHAR.
DEFINE VARIABLE pTip_Des   AS CHAR.
DEFINE VARIABLE pVlr_Des   AS CHAR.
DEFINE VARIABLE pForm_Pag  AS CHAR.
DEFINE VARIABLE pVlr_Pag   AS CHAR.
DEFINE VARIABLE pMsg_Pro   AS CHAR.



/*FUNÇÃO PARA ABRIR A PORTA*/
RUN ECF_AbrePortaSerial(OUTPUT pret).
/*MESSAGE pret
    VIEW-AS ALERT-BOX INFO BUTTONS OK.*/
IF pret = 1 THEN DO:
    MESSAGE "Porta aberta"/*MENSAGEM INFORMATIVA PARA CONFIRMAR QUE FOI ABERTA A PORTA*/
        VIEW-AS ALERT-BOX INFO BUTTONS OK.
END.



/*FUNÇÃO PARA ABRIR CUPOM FISCAL*/
pCNPJ = "123.456.789-00".
RUN ECF_AbreCupom(INPUT pCNPJ,OUTPUT pret).
MESSAGE pret
    VIEW-AS ALERT-BOX INFO BUTTONS OK.



/*FUNÇÃO PARA VENDER ITEM*/
pCodigo = "11111111111111". 
pDescricao = "Produto teste Inteiro".
paliq = "1800".      
pTip_Qtd = "I".   
pQtd = "0001".
pCas_dec = 2.  
pPrc_Uni = "00000100".  
pTip_Des = "%".   
pVlr_Des = "1000".  
RUN ECF_VendeItem(INPUT pCodigo,INPUT pDescricao,INPUT paliq,INPUT pTip_Qtd,INPUT pQtd,INPUT pCas_dec,INPUT pPrc_Uni,INPUT pTip_Des,INPUT pVlr_Des,OUTPUT pret).
MESSAGE pret
    VIEW-AS ALERT-BOX INFO BUTTONS OK.
/*FUNÇÃO PARA VENDER ITEM*/
pCodigo = "22222222222222". 
pDescricao = "Produto teste Fracionario".
paliq = "1200".      
pTip_Qtd = "F".   
pQtd = "0001500".
pCas_dec = 2.  
pPrc_Uni = "00000200".  
pTip_Des = "%".   
pVlr_Des = "0500".  
RUN ECF_VendeItem(INPUT pCodigo,INPUT pDescricao,INPUT paliq,INPUT pTip_Qtd,INPUT pQtd,INPUT pCas_dec,INPUT pPrc_Uni,INPUT pTip_Des,INPUT pVlr_Des,OUTPUT pret).
MESSAGE pret
    VIEW-AS ALERT-BOX INFO BUTTONS OK.



/*FUNÇÃO PARA EFETUAR O PAGAMENTO*/
pForm_Pag = "DINHEIRO".
pVlr_Pag = "0200".
RUN ECF_EfetuaFormaPagamento(INPUT pForm_Pag,INPUT pVlr_Pag,OUTPUT pret).
MESSAGE pret
    VIEW-AS ALERT-BOX INFO BUTTONS OK.
/*FUNÇÃO PARA EFETUAR O PAGAMENTO*/
pForm_Pag = "CARTAO".
pVlr_Pag = "0200".
RUN ECF_EfetuaFormaPagamento(INPUT pForm_Pag,INPUT pVlr_Pag,OUTPUT pret).
MESSAGE pret
    VIEW-AS ALERT-BOX INFO BUTTONS OK.



/*FUNÇÃO PARA FECHAR CUPOM*/
pMsg_Pro = "Volte sempre".
RUN ECF_TerminaFechamentoCupom(INPUT pMsg_Pro,OUTPUT pret).
MESSAGE pret
    VIEW-AS ALERT-BOX INFO BUTTONS OK.



/*FUNÇÃO PARA CANCELAR O CUPOM*/
/*RUN ECF_CancelaCupom(OUTPUT pret).
MESSAGE pret
    VIEW-AS ALERT-BOX INFO BUTTONS OK.*/




/*FUNÇÃO PARA FECHAR A PORTA*/
RUN ECF_FechaPortaSerial(OUTPUT pret).
/*MESSAGE pret
    VIEW-AS ALERT-BOX INFO BUTTONS OK.*/
IF pret = 1 THEN DO:
    MESSAGE "Porta fechada"/*MENSAGEM INFORMATIVA PARA CONFIRMAR QUE FOI FECHADA A PORTA*/
        VIEW-AS ALERT-BOX INFO BUTTONS OK.
END.



/*BLOCO DE PROCEDURES*/
PROCEDURE ECF_AbrePortaSerial EXTERNAL "c:\sweda\convecf.dll" STDCALL PERSISTENT.
  DEFINE RETURN PARAMETER pret AS LONG.
END.

PROCEDURE ECF_FechaPortaSerial EXTERNAL "c:\sweda\convecf.dll" STDCALL.
  DEFINE RETURN PARAMETER pret AS LONG.
END.


PROCEDURE ECF_AbreCupom EXTERNAL "c:\sweda\convecf.dll" STDCALL.
  DEFINE INPUT PARAMETER pCNPJ AS CHAR.
  DEFINE RETURN PARAMETER pret AS LONG.
END.

PROCEDURE ECF_VendeItem EXTERNAL "c:\sweda\convecf.dll" STDCALL.
  DEFINE INPUT PARAMETER pCodigo    AS CHAR.
  DEFINE INPUT PARAMETER pDescricao AS CHAR.
  DEFINE INPUT PARAMETER paliq      AS CHAR.
  DEFINE INPUT PARAMETER pTip_Qtd   AS CHAR.
  DEFINE INPUT PARAMETER pQtd       AS CHAR.
  DEFINE INPUT PARAMETER pCas_dec   AS LONG.
  DEFINE INPUT PARAMETER pPrc_Uni   AS CHAR.
  DEFINE INPUT PARAMETER pTip_Des   AS CHAR.
  DEFINE INPUT PARAMETER pVlr_Des   AS CHAR.
  DEFINE RETURN PARAMETER pret      AS LONG.

END.

PROCEDURE ECF_IniciaFechamentoCupom EXTERNAL "c:\sweda\convecf.dll" STDCALL.
  DEFINE INPUT PARAMETER pAcr_Des AS CHAR.
  DEFINE INPUT PARAMETER pTip_Des AS CHAR.
  DEFINE INPUT PARAMETER pVlr_Des AS CHAR.

END.

PROCEDURE ECF_EfetuaFormaPagamento EXTERNAL "c:\sweda\convecf.dll" STDCALL.
  DEFINE INPUT PARAMETER pForm_Pag AS CHAR.
  DEFINE INPUT PARAMETER pVlr_Pag  AS CHAR.
  DEFINE RETURN PARAMETER pret     AS LONG.
END.

PROCEDURE ECF_TerminaFechamentoCupom EXTERNAL "c:\sweda\convecf.dll" STDCALL.
  DEFINE INPUT PARAMETER pMsg_Pro AS CHAR.
  DEFINE RETURN PARAMETER pret    AS LONG.
END.


PROCEDURE ECF_CancelaCupom EXTERNAL "c:\sweda\convecf.dll" STDCALL.
  DEFINE RETURN PARAMETER pret AS LONG.
END.
